package xixirupan.tmgp.tencent.com.vmeim.login.presenter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.login.Model.CountriesBaen;
import xixirupan.tmgp.tencent.com.vmeim.login.Model.CountryBiz;
import xixirupan.tmgp.tencent.com.vmeim.login.Model.ICountryData;

/**
 * Created by lenovo on 2016/10/21.
 */

public class PopwindowPresenter {
    CountryBiz biz =new CountryBiz();
    Context context; LayoutInflater inflater;
    ListView listView;
    TextView textView1,  textView2;
    IPostData postData;
    public PopwindowPresenter(ListView listView,Context context, LayoutInflater inflater)
    {
        this.listView =listView;
        this.context=context;
        this.inflater=inflater;

    }
    public  void initListview(final IPostData postData)
    {
        this.postData =postData;

        biz.getData(new ICountryData() {
            @Override
            public void postCountryData(final List<CountriesBaen> countries) {
                PopwindowAdapter adapter =new PopwindowAdapter(context,inflater,countries);
                listView.setAdapter(adapter);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                       postData.postTextData(countries.get(position).getEnName(),countries.get(position).getAreaCode());
                    }
                });
            }
        });

    }
}
